<?php

/**
 * Shop form.
 *
 * @package    tsantek-shop
 * @subpackage form
 * @author     Tomislav Šantek
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class ShopForm extends BaseShopForm
{
  public function configure()
  {
    parent::configure();
    $this->getValidatorSchema()->setOption('allow_extra_fields', true);

    unset($this['created_at'], $this['updated_at'], $this['location_id'], /*$this['profile_id'],*/ $this['contact_id']);

    //$this->setWidget('description', new sfWidgetFormTextareaTinyMCE());

    $this->widgetSchema['slug'] = new sfWidgetFormInputHidden();
    $this->widgetSchema['pg_class_id'] = new sfWidgetFormChoice(array('choices'=> tsPaymentGateway::getChoices(true), 'label'=>'PG'));
    $this->validatorSchema['pg_class_id'] = new sfValidatorChoice(array('choices' => array_keys(tsPaymentGateway::getChoices()), 'required' => false));

    $this->setWidget('pic_path', new sfWidgetFormInputFileEditable(array(
            'file_src'    => '/uploads/shop/'.$this->getObject()->pic_path,
            'edit_mode'   => !$this->isNew(),
            'is_image'    => true,
            'with_delete' => false,
      )));

    $this->setValidator('pic_path', new sfValidatorFile(array(
                    'mime_types' => 'web_images',
                    'path' => sfConfig::get('sf_upload_dir') . '/shop',
                    'required' => false,
            )));

    $this->embedForm('frm_location', new LocationForm($this->getObject()->getLocation()));
    $this->embedForm('frm_contact', new ContactAdminForm($this->getObject()->getContact()));
  }
}
